﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.controllers {
    import flash.events.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.vo.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;
    import net.wooga.pets.controllers.startup.*;
    import net.wooga.pets.models.world.*;

    public class LetterButtonClickedCommand_W extends Command {

        public var event:InfoEvent;
        public var sunModel:SunModel;
        public var languageModel:LanguageModel;
        public var worldModel:WorldModel;
        public var gameViewModel:GameViewModel;
        public var roomSlotsModel:RoomSlotsModel;

        override public function execute():void{
            var _local2:String;
            var _local1:LetterVO = this.event.info.letterVO;
            _local1.isRead = true;
            this.sendLetterState(_local1.id);
            switch (_local1.id){
                case GameConstants.LETTER_MISSIONS:
                    dispatch(new InfoEvent(EventConstants.INIT_MISSION, EventConstants.SHOW_CURRENT_MISSION));
                    break;
                case GameConstants.LETTER_HOSPITAL_INFO:
                    break;
                case GameConstants.LETTER_INVITE_FRIEND:
                    dispatch(new Event(EventConstants.SHOW_FRIEND_INVITATION_WINDOW));
                    break;
                case GameConstants.LETTER_BUILD_TREATMENT_MENTAL:
                case GameConstants.LETTER_BUILD_TREATMENT_PHYSICAL:
                case GameConstants.LETTER_BUILD_REHA_SPORT:
                case GameConstants.LETTER_BUILD_TREATMENT_COSMETICS:
                case GameConstants.LETTER_BUILD_REHA_FUN:
                    this.openRoomMenu(_local1.roomTypeToBuild);
                    break;
                case GameConstants.LETTER_KIOSK:
                    this.gameViewModel.setGameScaleByIndex(GameViewModel.SCALE_3X3);
                    _local2 = "5";
                    dispatch(new InfoEvent(EventConstants.SHOW_ROOM, _local2));
                    break;
                case GameConstants.LETTER_FONTAIN:
                    break;
                default:
                    break;
            };
        }
        private function openRoomMenu(_arg1:String):void{
            if (((!(this.worldModel.hasAreaType(_arg1))) && (this.roomSlotsModel.freeSlots))){
                dispatch(new Event(EventConstants.OPEN_SHOP));
                dispatch(new InfoEvent(EventConstants.SELECT_SHOP_CATEGORY, null, {category:ShopItemVO.CATEGORY_ROOMS}));
                dispatch(new InfoEvent(EventConstants.SHOW_ARROW_IN_SHOP, _arg1));
            };
        }
        private function sendLetterState(_arg1:String):void{
            dispatch(new InfoEvent(EventConstants.SEND_LETTER_STATE, _arg1));
        }

    }
}//package net.wooga.pets.controllers 
